package com.example.emos.api.service.impl;

import com.example.emos.api.common.util.PageUtils;
import com.example.emos.api.db.dao.TbTemplateDao;
import com.example.emos.api.db.pojo.Tbtemplate;
import com.example.emos.api.service.TemplateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.HashMap;

/**
 * @author ：Supyo
 * @date ：Created in 2021/11/15 13:29
 * @description：
 */
@Service
public class TemplateServiceImpl implements TemplateService {
    @Autowired
    TbTemplateDao templateDao;

    @Override
    public PageUtils selectTemplateListBypages(HashMap param) {
        ArrayList<HashMap> list = templateDao.selectCheckListBypages(param);
        long count = templateDao.countTemplateList(param);
        int start = (Integer) param.get("start");
        int length = (Integer) param.get("length");
        PageUtils pageUtils = new PageUtils(list, count, start, length);
        return pageUtils;
    }

    @Override
    public Integer insert(Tbtemplate template) {
        int rows = templateDao.insert(template);
        return rows;
    }

    @Override
    public int updateTemplate(HashMap param) {
        int rows = templateDao.updateTemplate(param);
        return rows;
    }

    @Override
    public int deleteTemplateByIds(Integer[] ids) {
        int rows = templateDao.deleteTemplateByIds(ids);
        return rows;
    }

    @Override
    public Tbtemplate selectTemplateListById(Integer id) {
        Tbtemplate template = templateDao.selectTemplateListById(id);
        return template;
    }
}
